package com.prj.ufdm.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.prj.ufdm.cloud.ms.test.constants.ServiceNameConstant;

@SpringBootApplication
//@RibbonClients(value = {
//        @RibbonClient(name = ServiceNameConstant.SERVICE_MS_AUTH),
//        @RibbonClient(name = ServiceNameConstant.SERVICE_MS_WAREHOUSE),
//        @RibbonClient(name = ServiceNameConstant.SERVICE_MS_ORDER)
//})
@Controller
public class UfdmTestApplication extends SpringBootServletInitializer implements EnvironmentAware  {

	private static Environment env; 
	
	public static void main(String[] args) {
		SpringApplication.run(UfdmTestApplication.class, args); 
		System.out.println("\n MS-Test "+ env.getProperty("server.port") +" 启动成功................"); 
	}
	
	@Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(UfdmTestApplication.class);
    }
	
	@Override
	public void setEnvironment(Environment environment) {
		env = environment;
	}
	
	@RequestMapping("/")
	public String helloWorld(Model model) {
		model.addAttribute("hello", "hello");
		return "index";
	}
}
